using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace WPCoco
{
    /// <summary>
    /// Struct that store a size 
    /// </summary>
    public struct Size : IEquatable<Size>
    {
        public Size(int width, int height)
        {
            this.width = width; this.height = height;
        }

        int width;

        /// <summary>
        /// Current width
        /// </summary>
        public int Width
        {
            get { return width; }
            set { width = value; }
        }

        int height;
        /// <summary>
        /// Current height
        /// </summary>
        public int Height
        {
            get { return height; }
            set { height = value; }
        }

        #region IEquatable<Size> Members

        public bool Equals(Size other)
        {
            return this == other;
        }

        public override bool Equals(object obj)
        {
            if (!(obj is Size))
                return base.Equals(obj);

            return Equals((Size)obj);
        }

        public override int GetHashCode()
        {
            return (5 ^ width) & (3 ^ height);
        }

        #endregion

        public static bool operator == (Size a, Size b)
        {
            return a.width == b.width && a.height == b.height;
        }

        public static bool operator !=(Size a, Size b)
        {
            return a.width != b.width || a.height != b.height; ;
        }

        /// <summary>
        /// Convert from to a Vector2
        /// </summary>
        /// <returns></returns>
        public Vector2 ToVector2() 
        {
            return new Vector2(width, height);
        }

        public override string ToString()
        {
            return string.Format("With = {0}, Height = {1}", width, height);
        }
    }
}
